Ext.define("App.iteration.view.IterationEditor", {
    extend: 'Extend.window.FormWindow',
    alias: 'widget.iteration_editor',
    requires: ['App.project.field.ProjectComboBox'],
    config: {
        window: {
            title: '迭代信息编辑',
            width: 650,
            height: 400
        },
        entity: 'entity'
    },
    defaults: {
        columnWidth: 1,
        xtype: 'textfield',
        labelWidth: 120
    },
    items: [{
        fieldLabel: 'ID',
        name: 'id',
        hidden: true,
        allowBlank: true
    }, {
        xtype: 'hidden',
        name: 'project.id',
        allowBlank: true
    }, {
        xtype: 'numberfield',
        fieldLabel: '迭代编号',
        name: 'number',
        minValue: 1,
        beforeLabelTextTpl: ['<span style="color:red;">*</span>'],
        allowBlank: false,
        blankText: '不允许为空'
    }, {
        fieldLabel: '计划开始日期',
        name: 'planedStartDate',
        xtype: 'datefield',
        format: 'Y-m-d',
        editable: false,
        beforeLabelTextTpl: ['<span style="color:red;">*</span>'],
        allowBlank: false,
        blankText: '不允许为空'
    }, {
        fieldLabel: '计划结束日期',
        name: 'planedEndDate',
        xtype: 'datefield',
        format: 'Y-m-d',
        editable: false,
        beforeLabelTextTpl: ['<span style="color:red;">*</span>'],
        allowBlank: false,
        blankText: '不允许为空'
    }, {
        fieldLabel: '实际开始日期',
        name: 'actualStartDate',
        xtype: 'datefield',
        editable: false,
        format: 'Y-m-d'
    }, {
        fieldLabel: '实际结束日期',
        name: 'actualEndDate',
        xtype: 'datefield',
        editable: false,
        format: 'Y-m-d'
    }, {
        fieldLabel: '描述',
        name: 'description',
        beforeLabelTextTpl: [''],
        allowBlank: true,
        xtype: 'textarea'
    }, {
        fieldLabel: '创建人',
        name: 'creator',
        allowBlank: true,
        hidden: true
    }, {
        xtype: 'cdtcolumn',
        name: '创建时间',
        dataIndex: 'cdt',
        allowBlank: true,
        hidden: true
    }
    ],
    listeners: {
        load: function ($this, action) {
            var me = this;
            var data = action.result.data;
            if (!Ext.isEmpty(data.actualEndDate)) {
                me.down('[name="number"]').setReadOnly(true);
                me.down('[name="planedStartDate"]').setReadOnly(true);
                me.down('[name="planedEndDate"]').setReadOnly(true);
                me.down('[name="actualStartDate"]').setReadOnly(true);
                me.down('[name="actualEndDate"]').setReadOnly(true);
            }
        }
    }
});
